package ThreadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class ThreadPool {
    public static void main(String[] args) throws InterruptedException{
        ExecutorService service = Executors.newFixedThreadPool(4);
        for(int i = 0;i < 100;i ++){
            int id = i;
            service.submit(()->{
               Thread current = Thread.currentThread();
                System.out.println("hello thread " + id + "," + current.getName());
            });
        }
        Thread.sleep(2000);
        service.shutdown();
        System.out.println("程序退出");
    }
}
